#include<bits/stdc++.h>
#define N 10005
#define M 10005
using namespace std;
int T;
int n,m,L,V;
int d[N],v[N],a[N];
int p[N];
int dect[N][M],cartot[N],fnd[N][M],fndtot[N];
int cnt,ans;
double pointspeed(int dis,int v0,int av){
    return sqrt(v0*v0+2*av*dis);
}
void init(){
    memset(d,0,sizeof(d));
    memset(v,0,sizeof(v));
    memset(a,0,sizeof(a));
    memset(p,0,sizeof(p));
    memset(dect,0,sizeof(dect));
    memset(cartot,0,sizeof(cartot));
    memset(fnd,0,sizeof(fnd));
    memset(fndtot,0,sizeof(fndtot));
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    bool flag=false;
    while(T--){
        init();
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++) cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++) cin>>p[i];
        for(int i=1;i<=n;i++){//car
            flag=false;
            for(int j=1;j<=m;j++){
                if(p[j]<d[i]) continue;
                double ps=pointspeed(abs(p[j]-d[i]),v[i],a[i]);
                if(ps>V){
                    if(flag==false) cnt++,flag=true;
                    dect[cnt][++cartot[cnt]]=p[j];
                }
            }
        }//
        /*for(int i=1;i<=cnt;i++){
            for(int j=1;j<=cartot[i];j++){
                cout<<dect[i][j]<<" ";
            }
            cout<<endl;
        }
        cout<<cnt<<" ";*/
        int fcnt=0;
        if(cnt>1){
            while(1){
                for(int i=2;i<=cnt;i++){
                    flag=false;
                    for(int j=1;j<=cartot[i-1];j++){
                        for(int z=1;z<=cartot[i];z++){
                            if(dect[i][j]==dect[i][z]){
                                if(flag==false) fcnt++,flag=true;
                                fnd[fcnt][++fndtot[fcnt]]=dect[i][j];
                            }
                        }
                    }
                }
                for(int i=1;i<=fcnt;i++){
                    cartot[i]=fndtot[i];
                }
                cnt=fcnt;
                if(fcnt==1){
                    ans=fndtot[fcnt];
                    break;
                }
                /*for(int i=1;i<=fcnt;i++){
                    for(int j=1;j<=fndtot[i];j++){
                        cout<<fnd[i][j]<<" ";
                    }
                    cout<<endl;
                }*/
            }
        }
        else{
            cout<<m-1<<endl;
            return 0;
        }
        cout<<ans;
    }
    return 0;
}
